package cn.wolfcode.job;

import cn.wolfcode.cache.service.IStrategyStatisVORedisService;
import cn.wolfcode.cache.vo.StrategyStatisVO;
import cn.wolfcode.service.IStrategyService;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * redis数据持久化
 */
//@Component
public class RedisDataPersistenceJob {

    @Autowired
    private IStrategyStatisVORedisService strategyStatisVORedisService;
    @Autowired
    private IStrategyService strategyService;
    //秒 分 小时 月份中的日期 月份 星期中的日期 年份
    //0 0 0 1/1 * ? 
    @Scheduled(cron="0/10 * * * * ?")
    public void redisDataPersistence(){
        System.out.println("---------vo持久化-start-------");

        //查询redis中所有的vo对象
        List<StrategyStatisVO> vos = strategyStatisVORedisService.queryStrategyVoByPattern("*");

        for (StrategyStatisVO vo : vos) {
            strategyService.updateStrategyVo(vo);
        }


    }
}